﻿using MakeItWeb.Framework;
using System;

namespace AllNations.Controls
{
    public partial class LatestAnnouncements : MakeItWeb.Framework.MakeItWebUserControl
    {
        private int _PageSize = 100;
        private string _SectionCd = "Main";

        public int PageSize
        {
            get { return _PageSize; }
            set { _PageSize = value; }
        }

        public string SectionCd
        {
            get { return _SectionCd; }
            set { _SectionCd = value; }
        }

        protected string FormatAnnouncement(string sAnnouncement)
        {
            return sAnnouncement.Replace(Environment.NewLine, string.Format("{0}{1}", "<br/>", Environment.NewLine));
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                StoredProcArgs args = new StoredProcArgs();
                args["pSectionCd"] = SectionCd;
                args["pCount"] = PageSize;
                rptAnnouncements.DataSource = GenericQry.GetDataSet("proc_cm_ListLatestAnnouncement", args);
                rptAnnouncements.DataBind();
            }
        }

        private int _ItemCount = 0;
        protected string GetClassName()
        {
            return (++_ItemCount % 2 == 0) ? "even" : "odd";
        }
    }
}